<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>后台管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="./css/x-admin.css" media="all">
<script type = "text/javascript"  src="ueditor/ueditor.config.js"></script>
<script type = "text/javascript"  src="ueditor/ueditor.all.min.js"></script>
<script type = "text/javascript"  src="ueditor/lang/zh-cn/zh-cn.js"></script>

</head>
<body>
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a><cite>首页</cite></a> <a><cite>员工管理</cite></a>
			<a><cite>员工课程申请</cite></a> <a><cite>申请修改</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	
	<%
	String empno = request.getParameter("empNo");
	int empNo = Integer.parseInt(empno);
	String courseNo = request.getParameter("courseNo");
	String percourseno = request.getParameter("perCourseNo");
	int perCourseNo = Integer.parseInt(percourseno);
	
	%>
	
	
	
	<div class="x-body">
		<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<form class="layui-form layui-form-pane" action="PerCourseServlet?op=updatePerCouse" method="post">
						<input type="hidden" name="id" value="" />
						
						<div class="layui-form-item">
							<label class="layui-form-label"> <span class='x-red'>*</span>申请编号
							</label>
							<div class="layui-input-block">
								<input type="text" name="perCourseNo" autocomplete="off"
									 class="layui-input" lay-verify="required"  readonly id = "perCourseNo"
									value="<%=perCourseNo%>" >
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label"> <span class='x-red'>*</span>员工编号
							</label>
							<div class="layui-input-block">
								<input type="hidden" name="selectempno" id = "selectempno" value="<%=empNo%>">
								<select name="empNo" id="empNo"></select>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"> <span class='x-red'>*</span>课程编号
							</label>
							<div class="layui-input-block">
								<input type="hidden" name="selectcpno" id="selectcpno" value="<%=courseNo%>">
								<select name="cpNo" id="cpNo"></select>
							</div>
						</div>
						<div class="layui-form-item">
							<input class="layui-btn" type="button" lay-submit lay-filter="*" value="保存">
						</div>
					</form>
					<div style="height: 200px;"></div>
				</div>
			</div>
		</div>
	</div>
	<script src="lib/layui/layui.js" charset="utf-8"></script>
	<script src="js/x-layui.js" charset="utf-8"></script>
	<script src="./js/jquery-2.0.3.js" charset="utf-8"></script>
	<script>
		layui.use([ 'element', 'layer', 'form' ], function() {
			$ = layui.jquery;//jquery
			lement = layui.element();//面包导航
			layer = layui.layer;//弹出层
			form = layui.form();

			//监听提交
			form.on('submit(*)', function() {
				var empNo = $("#empNo").val();
				var cpNo = $("#cpNo").val();
				var perCourseNo = $("#perCourseNo").val();
			//	var data = data.field;
				console.log("empNo:"+empNo)
				$.ajax({
					type : "post",
					url : "PerCourseServlet",
					data : {empNo:empNo,cpNo:cpNo,perCourseNo:perCourseNo,op:"updatePerCourse"},
					dataType : "json",
					success : function(data) {
						if (data == true) {
							layer.msg("编辑成功！", {
								icon : 1,
								time : 1000
							});
							setTimeout(function() {
								window.parent.location.reload();
								var index = parent.layer
										.getFrameIndex(window.name);
								parent.layer.close(index);
							}, 1000);
							return false;
						} else {
							layer.msg("编辑失败！", {
								icon : 5,
								time : 1000
							});
							return false;
						}
					}
				});
				return false;
			});

		})
	</script>

		<script type="text/javascript">
		var selectempno = $("#selectempno").val();
		var selectcpno = $("#selectcpno").val();
		$(function() {
			$.get("EmpServlet?op=ajaxReq", function(data) {
				$("#empNo").append("<option value="+selectempno+">" + selectempno + "</option>");
				$.each(data, function(index, emp) {
					if( emp.empNo != selectempno){
						$("#empNo").append("<option value="+emp.empNo+">" + emp.empNo + "</option>");
					}
				});
			});
			
			$.get("CoursePlanServlet?op=ajaxReq", function(data) {
				$("#cpNo").append("<option value="+selectcpno+">" + selectcpno + "</option>");
				$.each(data, function(index, cp) {
					if(cp.cpNo != selectcpno){
						$("#cpNo").append("<option value="+cp.cpNo+">" + cp.cpNo + "</option>");
					}
				});
			});
			
		});
	</script>
	
</body>
</html>
